/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.difsonapps.contacttranslator.dto;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;



/**
 *
 * @author difson
 */
@Entity
@Table(name="socialcontact")
public class SocialContactDTO  implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
	
	@Column(name="value")
    private String value;
	@Column(name="description")
    private String description;
    
	@Column(name="type") 
	@Enumerated(EnumType.ORDINAL)
	private SocialContactTypeEnum type;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idcontact")
	@JsonIgnore
	private ContactDTO contactDTO;
	
	public SocialContactDTO() {
		super();
		// TODO Auto-generated constructor stub
	}

	public SocialContactDTO(String value, SocialContactTypeEnum type) {
		super();
		this.value = value;
		this.type = type;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public SocialContactTypeEnum getType() {
		return type;
	}

	public void setType(SocialContactTypeEnum type) {
		this.type = type;
	}

	public ContactDTO getContactDTO() {
		return contactDTO;
	}

	public void setContactDTO(ContactDTO contactDTO) {
		this.contactDTO = contactDTO;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	@Override
	public boolean equals(Object object) {
		boolean sameSame = false;

		if (object != null && object instanceof SocialContactDTO) {
			sameSame = this.value.compareTo(((SocialContactDTO) object).getValue()) == 0;
		}

		return sameSame;
	}
	
}
